import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Layout from "../layout/Index.vue";
import User from "../views/User.vue";
import Calligraphist from "../views/Calligraphist.vue";
import Property from "../views/Property.vue";
import Material from "../views/Material.vue";
import Style from "../views/Style.vue";
import Event from "../views/Event.vue";
import Article from "../views/Article.vue";
import Center from "../views/Center.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/layout",
    name: "Layout",
    component: Layout,
    redirect: "/user",
    children: [
      {
        path: "/user",
        component: User,
      },
      {
        path: "/calligraphist",
        component: Calligraphist,
      },
      {
        path: "/property",
        component: Property,
      },
      {
        path: "/material",
        component: Material,
      },
      {
        path: "/style",
        component: Style,
      },
      {
        path: "/event",
        component: Event,
      },
      {
        path: "/article",
        component: Article,
      },
      {
        path: "/center",
        component: Center,
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

// router.beforeEach((to, from, next) => {
//   if (localStorage.getItem("jobAdminUserId")) {
//     next();
//   } else {
//     next({
//       path: '/login'
//     });
//   }
// })

export default router;
